package leetcode.jianzhioffer;

import javax.swing.tree.TreeNode;
import java.util.*;

/**
 * @program: datastructureandalogorithm
 * @description:
 * @author: hmx
 * @create: 2021-10-28 16:20
 **/
public class JinaZhiOffer32I {

    /*public int[] levelOrder(TreeNode root) {
        //存储遍历的元素
        List<Integer> list = new ArrayList<>();
        if (root == null) {
            return new int[0];
        }
        Deque<TreeNode> queue = new LinkedList<>();
        queue.offer(root);

        //存储临时节点
        TreeNode temp = null;
        while (!queue.isEmpty()) {
            //记录当前层元素个数
            int size = queue.size();
            //遍历当层元素
            for (int i = 0; i < size; i++) {
                temp = queue.poll();
                list.add(temp.val);
                if (temp.left != null) {
                    queue.offer(temp.left);
                }
                if (temp.right != null) {
                    queue.offer(temp.right);
                }
            }
        }
        //结果数组
        int[] result = new int[list.size()];
        //指向数组当前索引
        int index = 0;
        for (int num : list) {
            result[index++] = num;
        }
        return result;
    }*/

}
